﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace ProjektXNA
{
    class Sprite
    {
        protected Texture2D sprite;

        protected Vector2 position;
        protected Vector2 center;
        protected Vector2 origin;//Mitten av texturen

        protected Vector2 speed;

        protected float rotation;

        public Vector2 Center { get { return center; } }
        public Vector2 Position { get { return position; } }

        public Sprite(Texture2D texture, Vector2 pos)
        {
            sprite = texture;
            position = pos;
            speed = Vector2.Zero;
            center = new Vector2((position.X + sprite.Width) / 2, (position.Y + sprite.Height) / 2);
            origin = new Vector2(sprite.Width / 2, sprite.Height / 2);
        }

        public virtual void Update(GameTime gameTime)
        {
            this.center = new Vector2((position.X + sprite.Width) / 2, (position.Y + sprite.Height) / 2);
        }

        public virtual void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(sprite, center, null, Color.White, rotation, origin, 1.0f, SpriteEffects.None, 0);
        }

        public virtual void Draw(SpriteBatch spriteBatch, Color color)
        {
            spriteBatch.Draw(sprite, center, null, color, rotation, origin, 1.0f, SpriteEffects.None, 0);
        }
    }
}
